const {getAdmins ,delAdmins,addAdmins,changeAdmins, changeAdminsCode}=require('../dao/adminsDao');


//管理员列表
module.exports.getAdmins = async function (num) {
  const data = await getAdmins(num);
  // console.log(data, 222);
  return {
    message: "管理员数据获取成功",
    state: 1,
    data,
  };
};
//删除管理员
module.exports.delAdmins = async function (id) {
  const data = await delAdmins(id);
  if (data.nModified) {
    return {
      message: "删除成功",
      state: 1,
    };
  }
};

//新增管理员
module.exports.addAdmins = async function (item) {
  const data = await addAdmins(item);
  // console.log(data,22222);
  if (data) {
    return {
      message: "添加成功",
      state: 1,
      data,
    };
  } else {
    return {
      message: "添加失败",
      state: 0,
    };
  }
};

//修改管理员
module.exports.changeAdmins = async function (item) {
    const data = await changeAdmins(item);
    if(data.nModified){
        return {
        message: '修改学生数据获取成功',
        state: 1,
    }
    }
    
}

//修改管理员权限
module.exports.changeAdminsCode = async function (item) {
    const data = await changeAdminsCode(item)
    if(data) {
        return {
            status: 1,
            message: '修改成功'
        }
    }
}


